package cn.bandeqing.product.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.product.req.EvaluateListReq;
import cn.bandeqing.product.req.ProductDetailReq;
import cn.bandeqing.product.req.ProductListReq;
import cn.bandeqing.product.resp.EvaluateDetail;
import cn.bandeqing.product.resp.ProductDetailResp;
import cn.bandeqing.product.resp.ProductListResp;
import cn.bandeqing.product.rpc.IProductRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "产品")
@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {

    @DubboReference
    private IProductRpc productRpc;

    @Operation(summary = "评价详情")
    @PostMapping("/evaluateList")
    public Resp<List<EvaluateDetail>> evaluateList(@RequestBody @Valid EvaluateListReq req) {
        return productRpc.evaluateList(req);
    }

    @Operation(summary = "产品详情")
    @PostMapping("/detail")
    public Resp<ProductDetailResp> detail(@RequestBody @Valid ProductDetailReq req) {
        return productRpc.detail(req);
    }

    @Operation(summary = "产品列表")
    @PostMapping("/list")
    public Resp<List<ProductListResp>> list(@RequestBody @Valid ProductListReq req) {
        return productRpc.list(req);
    }

}
